package edu.washington.cs.sounddetector.server.api.method;

import java.util.List;

import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.ToStringBuilder;

import edu.washington.cs.sounddetector.server.api.Method;
import edu.washington.cs.sounddetector.server.api.object.LabeledSound;
import edu.washington.cs.sounddetector.server.api.object.SoundFormat;

public class Train implements Method
{

    private String detectorId;
    private List<LabeledSound> data;
    private SoundFormat soundFormat;

    public Train()
    {
    }

    public Train(String detectorId, List<LabeledSound> data, SoundFormat soundFormat)
    {
        Validate.notBlank(detectorId);
        Validate.notEmpty(data);
        Validate.noNullElements(data);
        Validate.notNull(soundFormat);

        this.detectorId = detectorId;
        //this.data = data.toArray(new LabeledSound[0]);
        this.data = data;
        this.soundFormat = soundFormat;
    }

    /**
     * @param detectorId
     *            the detectorId to set
     */
    public void setDetectorId(String detectorId)
    {
        this.detectorId = detectorId;
    }

    /**
     * @param data
     *            the data to set
     */
    public void setData(List<LabeledSound> data)
    {
        this.data = data;
    }

    /**
     * @param soundFormat
     *            the soundFormat to set
     */
    public void setSoundFormat(SoundFormat soundFormat)
    {
        this.soundFormat = soundFormat;
    }

    /**
     * @return the detectorId
     */
    public String getDetectorId()
    {
        return detectorId;
    }

    /**
     * @return the data as an unmodifiable list
     */
    public List<LabeledSound> getData()
    {
        return data;
    }

    /**
     * @return the soundFormat
     */
    public SoundFormat getSoundFormat()
    {
        return soundFormat;
    }

    @Override
    public String toString()
    {
        return new ToStringBuilder(this).append("detectorId", detectorId).append("data", data)
                .append("soundFormat", soundFormat).toString();
    }
}
